package com.bhs.sansong.adapter;

import android.text.TextUtils;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.bhs.sansong.R;
import com.bhs.sansong.bean.MessageBean;
import com.bhs.sansong.utils.DateUtils;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.List;

public class MessageAdapter extends BaseQuickAdapter<MessageBean, BaseViewHolder> {

    public MessageAdapter(int layoutResId, @Nullable List<MessageBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(@NonNull BaseViewHolder helper, MessageBean item) {
        helper.setImageResource(R.id.iv_head, item.getIcon());
        helper.setText(R.id.tv_title, item.getTitle());
        helper.setVisible(R.id.view, item.getCount() > 0);
        helper.setText(R.id.tv_content, TextUtils.isEmpty(item.getContent()) ? "暂无消息" : item.getContent());
        helper.setVisible(R.id.view_line, helper.getLayoutPosition() != mData.size() - 1);
        helper.setText(R.id.tv_time, item.getCreate_time() > 0 ? DateUtils.descriptiveData(item.getCreate_time()) : "");
    }
}
